Input from Comma Separated Data (CSV) File

Related example macros: Demo-ReadCSV, Script: CSV-2-web.vbs, Database-2-web.vbs

Internet Macros allows you to specify a text file with comma separated values as input, for example:

"ARTIST"
 "ALBUM TITLE" , "PRICE"
"Beatles""Abbey Road""13.49"
"Beatles""The Beatles 1,2,3" , "25.49"
"Mozart" , "Symphonies No.40 & 41""9.98"
"
Mozart""Requiem""7.50"

Note: Quotation marks "" are optional in most cases. They are only required if the value itself contains a comma.
   
Important: If you read data from a datasource in "CSV" format, the variable names must be of the format !COL1, !COL2, ...,!COL10 for the values of column 1, 2,...10 of the input file. You can not use user defined names like if you use the "List of Variables" format as input.

The Internet Macros file contains the location of the data files:

SET !DATASOURCE OnlineAuction.csv
SET !DATASOURCE_COLUMNS 3
SET !DATASOURCE_LINE {{!LOOP}}
TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Name CONTENT={{!COL1}}
  
TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Album CONTENT={{!COL2}}
  
TAG TYPE=INPUT:TEXT FORM=Listing ATTR=NAME:Price CONTENT={{!COL3}}
  

With the "SET !DATASOURCE_COLUMNS 3you specify the number of columns in the input file (3 in our example). This number must match the exact number of columns in the input file, even if you do not usee some columns.

With
SET !DATASOURCE_LINE {{!LOOP}}you tell IIM which line of the file to read. In our example we use the !LOOP variable read the next line in the input file with each loop.

During the execution of the macro, the constants in parentheses {{..}} are replaced by the value specified in the data sources. The file name of the data source is stored in the variable !DATASOURCE. This variable can be filled from the command line if required.